package com.yoso.shop.infrastructure.constants.user;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author shizejin
 * @date 2021/11/17
 * @description:
 */
public enum Sex {
    /**
     * 性别 男
     */
    MAN("0", "男"),
    /**
     * 性别 女
     */
    WOMAN("1", "女");
    String code;
    String value;

    Sex(String code, String value) {
        this.code = code;
        this.value = value;
    }
    private static Map<String,String> sexMap = new HashMap<>();
    static {
        for (Sex sex : values()) {
            sexMap.put(sex.getCode(),sex.getValue());
            sexMap.put(sex.getValue(),sex.getCode());
        }
    }
    /**
     * 下拉列表
     */
    public static Map<String,String> selectListMap = new LinkedHashMap<>();
    public static Map<String,String> getSelectList(){
        for (Sex sex : values()) {
            selectListMap.put(sex.getCode(),sex.getValue());
        }
        return selectListMap;
    }

    /**
     * 编号和值的转换
     */
    public static String transformSex(String e){
        return sexMap.get(e);
    }
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
